package com.carryking.smart.rpc.utils;

import com.carryking.smart.rpc.proxy.ClientServiceInvokeHandler;

import java.lang.reflect.Proxy;

/**
 * Created by jincarry on 2018/1/11.
 */
public class ClientBeanProxyUtils {
    public static <T> T newInstance(Class<T> ownInterface,int timeOut) {
        ClassLoader classLoader = ownInterface.getClassLoader();
        Class<?>[] interfaces = new Class[]{ownInterface};
        ClientServiceInvokeHandler proxy = new ClientServiceInvokeHandler(timeOut);
        return (T) Proxy.newProxyInstance(classLoader, interfaces, proxy);
    }
}
